-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add error for old castep_bin files #296
Conversation
The cell_origins = _read_entry(f, int_type)
if isinstance(cell_origins, int):
raise ValueError('Old castep file detected: '
'Euphonic only supports post-Castep 17.1 files. '
'Please rerun the calculation with a newer version '
'of Castep with the original .cell file and a '
'.castep file with a single line with the '
'"continuation: <old.castep_bin>" keyword and '
'use the new output .castep_bin file in Euphonic.')
cell_origins = np.reshape(cell_origins, (n_cells_in_sc, 3)) be a bit safer? |
Ok, have pushed that up. It would be helpful to have a small reference file so we can test that the right error is raised. @krefson would you happen to have a very small and old .castep_bin file with force constants we can add to the test set? The unit test failures seem to be spglib-related, probably there was a breaking API change? I'll take a look. |
Thanks Adam! I was going to try to look into the test failure - it doesn't seem to be related to this (I get the same errors on |
The dump files contain a version number, and I suggest checking against that. The checkpoint version is encoded as a floating-point number as ASCII in a character*10 field in the record immediately following BEGIN_PARAMETERS_DUMP. The format change was introduced in CASTEP 17.x, so testing for < 17.0 and reporting "not supported" should work as a robust safeguard. |
If you really wanted to read dump files with version <= 16.x, then you will indeed need to recompute the supercell_origins vector. There is a short Fortran routine cell.f90 named |
I don't think we need to support CASTEP versions < 17, especially if an external workaround is available. I'll implement the version number check, that seems a better way of handling things. |
Ok, I am using
|
I think we should wait until #298 is merged and rebase this branch in order to get a clean error check before a final review/merge. |
"except ValueError" is a bit broad and could catch unrelated problems. Checking that _read_entry returned an int is still not 100% specific to the problem but seems safer.
1143f82
to
bc54df3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks for making the check much better!
In the interest of keeping a clean commit history maybe we ought to actually close this PR unmerged and create a new one with just the last commit (checking the Castep version in the .castep_bin
file)?
We can also achieve that from this PR with the "squash and merge" option. I'll add a changelog line first, though. |
Adds a more helpful error message if users try to use old castep_bin file (pre Castep-17.1).
An alternative fix would involve calculating the
supercell_origins
field. Some code used in the phonopy reader could possibly be re-used for this.Fixes #295